package com.s.core.root.data;

import com.c1.client.pan.PanConf;
import com.s.core.root.D;
import com.s.core.root.strategy.factor.pic.F_Pic_ActivityMax;
import com.s.core.root.strategy.factor.pic.F_Pic_ActivityPair;
import com.s.core.root.strategy.factor.pic.F_Pic_LastBigMaxStrong;
import com.s.core.root.strategy.factor.point.*;

import java.math.BigDecimal;

public class _PointN extends _BasePoint {
    public int n;
    public boolean isRemainder;

    public _PointN(_BasePic pic, D d, int total, int recentIndex, int n, boolean isRemainder) {
        super(pic, d, total, recentIndex);
        this.n = n;
        this.isRemainder = isRemainder;
    }

    @Override
    public int posValue() {
        return d.getPosN(n);
    }

    @Override
    public BigDecimal volValue() {
        return new BigDecimal(d.volN(n));
    }

    @Override
    protected InfoAndStyle yInfoValue() {
        if (isRemainder && containFeature(F_Point_Strong.class)) {
            if (pic.containFeature(F_Pic_ActivityMax.class) || pic.containFeature(F_Pic_ActivityPair.class)) {
                return new InfoAndStyle(String.valueOf(pos()), PanConf.me().yInfoStyle_);
            }
            return new InfoAndStyle(String.valueOf(pos()), PanConf.me().yInfoStyle);
        } else if (!isRemainder && recentIndex == 0 && containFeature(F_Point_Strong.class)) {
            return new InfoAndStyle(String.valueOf(pos()), PanConf.me().yInfoStyle);
        } else {
            return null;
        }
    }

    @Override
    protected InfoAndStyle xInfoValue() {
        if (recentIndex == 0) {
            if (isRemainder) {
                return new InfoAndStyle(n + "/" + (n + 1), PanConf.me().xInfoStyle);
            } else {
                return new InfoAndStyle(n + "/" + n, PanConf.me().xInfoStyle);
            }
        }
        return null;
    }

    @Override
    protected PanConf.PosStyle posStyleValue() {
        return PanConf.me().commonPosStyle;
    }

    @Override
    protected PanConf.CjlStyle cjlStyleValue() {
        if (isRemainder && containFeature(F_Point_Max.class)) {
            if (containFeature(F_Point_Last.class) &&
                    containFeature(F_Point_Strong.class)) {
                if (pic.containFeature(F_Pic_LastBigMaxStrong.class)) {
                    return PanConf.me().cjlLastBigMaxVolAndStrongStyle;
                } else {
                    return PanConf.me().cjlLastMaxVolAndStrongStyle;
                }
            } else if (pic.containFeature(F_Pic_ActivityMax.class)) {
                return PanConf.me().cjlLastMaxVolAndStrongStyle;
            }
        }
        return PanConf.me().cjlStyle;
    }
}
